package com.fr.privilege.manager;

import com.fr.base.FCloneable;
import com.fr.base.XMLFileManager;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.privilege.authority.Control;
import com.fr.privilege.authority.NoAuthorityControl;
import com.fr.privilege.providers.AuthenticationProvider;
import com.fr.privilege.providers.NoAuthenticationProvider;
import com.fr.report.io.xml.ReportXMLUtils;
import java.io.Serializable;

public class PrivilegeManager extends XMLFileManager
  implements Serializable, FCloneable
{
  public static final String XML_TAG = "PrivilegeManager";
  private AuthenticationProvider authenticationProvider = new NoAuthenticationProvider();
  private Control control = new NoAuthorityControl();

  public boolean usePrivilege()
  {
    return ((!(this.authenticationProvider instanceof NoAuthenticationProvider)) || (!(this.control instanceof NoAuthorityControl)));
  }

  public AuthenticationProvider getAuthenticationProvider()
  {
    return this.authenticationProvider;
  }

  public void setAuthenticationProvider(AuthenticationProvider paramAuthenticationProvider)
  {
    this.authenticationProvider = paramAuthenticationProvider;
  }

  public Control getControl()
  {
    return this.control;
  }

  public void setControl(Control paramControl)
  {
    this.control = paramControl;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("AP"))
        this.authenticationProvider = ((AuthenticationProvider)ReportXMLUtils.readXMLable(paramXMLableReader));
      else if ("Control".equals(str))
        this.control = ((Control)ReportXMLUtils.readXMLable(paramXMLableReader));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("PrivilegeManager");
    if (this.authenticationProvider != null)
      ReportXMLUtils.writeXMLable(paramXMLPrintWriter, this.authenticationProvider, "AP");
    if (this.control != null)
      ReportXMLUtils.writeXMLable(paramXMLPrintWriter, this.control, "Control");
    paramXMLPrintWriter.end();
  }

  public String fileName()
  {
    return "privilege.xml";
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    PrivilegeManager localPrivilegeManager = (PrivilegeManager)clone();
    if (this.authenticationProvider != null)
      localPrivilegeManager.authenticationProvider = this.authenticationProvider;
    if (this.control != null)
      localPrivilegeManager.control = this.control;
    return localPrivilegeManager;
  }
}